package com.bond.cloud.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bond.cloud.po.TestData;
import com.bond.cloud.producer.TestServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class TestController {

    @Autowired
    private TestServiceImpl testService;

    @PostMapping("save")
    public TestData save(@RequestBody TestData testData) {
        return testService.save(testData);
    }

    @GetMapping("/getById")
    public TestData getById(@RequestParam Long id) {
        return testService.getById(id);
    }

    @PostMapping("pageQuery")
    public Page<TestData> pageQuery(@RequestBody Page<TestData> pageQuery) {
        return testService.myPage(pageQuery);
    }

    @PostMapping("pageQuery2")
    public Page<TestData> pageQuery(@RequestBody TestData pageParams, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int pageSize) {
        return testService.myPage(pageParams, pageNum, pageSize);
    }

}
